package com.iwdm.renovation.ui.furniture.details;

import android.os.Bundle;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import androidx.appcompat.app.AppCompatActivity;
import com.iwdm.renovation.databinding.ActivityDesignerBinding;

import java.util.Random;

public class FurnitureActivity extends AppCompatActivity {
    private ActivityDesignerBinding binding;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        binding = ActivityDesignerBinding.inflate(getLayoutInflater());
        setContentView(binding.getRoot());
        Random random = new Random();
        int position = random.nextInt(2);
        binding.web.loadUrl("file:///android_asset/furniture"+position+".html");
        // 如果页面中链接，如果希望点击链接继续在当前browser中响应，
        // 而不是新开Android的系统browser中响应该链接，必须覆盖webview的WebViewClient对象
        binding.web.setWebViewClient(new WebViewClient() {
            public boolean shouldOverrideUrlLoading(WebView view, String url) { //  重写此方法表明点击网页里面的链接还是在当前的webview里跳转，不跳到浏览器那边
                view.loadUrl(url);
                return true;
            }
        });
    }
}
